package com.tulingxueyuan.mall.config;

import com.tulingxueyuan.mall.modules.ums.service.UmsMemberService;
import com.zhaofuhao.config.SecurityConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

/**
 * @author ：扫地僧
 * @date ：2022/3/16/0016 10:59:29
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 * @description:
 **/
@Configuration
@EnableWebSecurity //启动
public class MallSecurityConfig extends SecurityConfig {
    @Autowired
    private UmsMemberService memberService;

    /**
     *  认证交给springSecurity管理
     * @return
     */
   @Bean
    public UserDetailsService userDetailsService(){
       return  userName -> memberService.loadUserByUsername(userName);
   }

}
